package cn.bdqn.easyexcel_web.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.excel.EasyExcel;

import cn.bdqn.easyexcel_web.listener.ExcelListener;
import cn.bdqn.easyexcel_web.pojo.User;
import cn.bdqn.easyexcel_web.service.UserService;

@Controller
public class ExcelController {
	@Autowired
	private UserService userService;
	@ResponseBody
	@GetMapping("/showInfo")
	public Object getInfo() {
		return userService.listAll();
	}
	@GetMapping("/upload")
	public String index() {
		return "index";
	}
	@PostMapping("/upload")
	@ResponseBody
	public String upload(MultipartFile file) throws Exception {
		EasyExcel.read(file.getInputStream(), User.class, new ExcelListener()).sheet().doRead();
		return "success";
	}
	
}
